package com.dems.admin.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dems.admin.security.SecurityUtils;
import com.dems.dao.dataobject.CfgAlarmStrategy;
import com.dems.domain.AlarmStrategyReqVO;
import com.dems.domain.JsonResponse;
import com.dems.service.CfgAlarmStrategyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/alarmStrategy")
public class AlarmStrategyController {

    @Autowired
    private CfgAlarmStrategyService cfgAlarmStrategyService;

    @PostMapping("/find")
    public JsonResponse<Page<CfgAlarmStrategy>> find(@RequestBody AlarmStrategyReqVO alarmStrategyReqVO){
        return JsonResponse.success(cfgAlarmStrategyService.queryAlarmStrategyByPage(alarmStrategyReqVO));
    }

    @PostMapping("/create")
    public JsonResponse<Integer> createStrategy(@RequestBody CfgAlarmStrategy cfgAlarmStrategy){
        return JsonResponse.success(cfgAlarmStrategyService.create(cfgAlarmStrategy, SecurityUtils.getLoanassistUser()));
    }

    @PostMapping("/update")
    public JsonResponse updateStrategy(@RequestBody CfgAlarmStrategy cfgAlarmStrategy){
        return JsonResponse.success(cfgAlarmStrategyService.update(cfgAlarmStrategy, SecurityUtils.getLoanassistUser()));
    }
}
